<!DOCTYPE html><html lang="zh-CN" data-theme="dark"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>ios崩溃调试与xcode高级管理 | Albert Yuan's Blog</title><meta name="keywords" content="iOS测试"><meta name="author" content="Albert Yuan"><meta name="copyright" content="Albert Yuan"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#0d0d0d"><meta name="referrer" content="no-referrer"><meta name="description" content="Tools to Help You Fix and Resolve Crashes（崩溃处理工具） Breakpoints    直接打断点：（确定大概位置的情况下）  异常断点(exception breakpoint)：Debug navigator—- 左下角的+ —- 选择&#96;Exception Breakpoint 异常断点是由Objective-C运行时中发生的错误触发的，这在大">
<meta property="og:type" content="article">
<meta property="og:title" content="ios崩溃调试与xcode高级管理">
<meta property="og:url" content="https://yllove.gitee.io/2021/12/01/%E6%B5%8B%E8%AF%95%E4%B8%8E%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/index.html">
<meta property="og:site_name" content="Albert Yuan&#39;s Blog">
<meta property="og:description" content="Tools to Help You Fix and Resolve Crashes（崩溃处理工具） Breakpoints    直接打断点：（确定大概位置的情况下）  异常断点(exception breakpoint)：Debug navigator—- 左下角的+ —- 选择&#96;Exception Breakpoint 异常断点是由Objective-C运行时中发生的错误触发的，这在大">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://yllove.gitee.io/img/defaultCover.png">
<meta property="article:published_time" content="2021-12-01T03:47:03.607Z">
<meta property="article:modified_time" content="2022-05-24T04:01:16.011Z">
<meta property="article:author" content="Albert Yuan">
<meta property="article:tag" content="iOS测试">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://yllove.gitee.io/img/defaultCover.png"><link rel="shortcut icon" href="/blog/img/favicon.png"><link rel="canonical" href="https://yllove.gitee.io/2021/12/01/%E6%B5%8B%E8%AF%95%E4%B8%8E%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta/><link rel="stylesheet" href="/blog/css/index.css"><link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.css" media="print" onload="this.media='all'"><script src="https://fastly.jsdelivr.net/npm/instantsearch.js@2.10.5/dist/instantsearch.min.js" defer></script><script>const GLOBAL_CONFIG = { 
  root: '/blog/',
  algolia: {"appId":"X8NS0XSX99","apiKey":"b9d4530647c8b5bf7928a04c47752ad7","indexName":"albertyuan","hits":{"per_page":6},"languages":{"input_placeholder":"搜索文章","hits_empty":"找不到您查询的内容：${query}","hits_stats":"找到 ${hits} 条结果，用时 ${time} 毫秒"}},
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"highlighjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: false
  },
  runtime: '天',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: undefined,
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://fastly.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://fastly.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://fastly.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://fastly.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://fastly.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: true,
  islazyload: true,
  isanchor: true
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'ios崩溃调试与xcode高级管理',
  isPost: true,
  isHome: false,
  isHighlightShrink: true,
  isToc: true,
  postUpdate: '2022-05-24 12:01:16'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    
    const detectApple = () => {
      if (GLOBAL_CONFIG_SITE.isHome && /iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)){
        document.documentElement.classList.add('apple')
      }
    }
    detectApple()
    })(window)</script><meta name="generator" content="Hexo 6.2.0"><link rel="alternate" href="/blog/atom.xml" title="Albert Yuan's Blog" type="application/atom+xml">
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="avatar-img is-center"><img src= "" data-lazy-src="/blog/img/favicon.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">155</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">56</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('/blog/img/defaultCover.png')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/blog/">Albert Yuan's Blog</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/blog/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/blog/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/blog/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="/blog/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/blog/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">ios崩溃调试与xcode高级管理</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-12-01T03:47:03.607Z" title="发表于 2021-12-01 11:47:03">2021-12-01</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2022-05-24T04:01:16.011Z" title="更新于 2022-05-24 12:01:16">2022-05-24</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/blog/categories/iOS%E6%B5%8B%E8%AF%95/">iOS测试</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">3.4k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>13分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title="ios崩溃调试与xcode高级管理"><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><h4 id="Tools-to-Help-You-Fix-and-Resolve-Crashes（崩溃处理工具）"><a href="#Tools-to-Help-You-Fix-and-Resolve-Crashes（崩溃处理工具）" class="headerlink" title="Tools to Help You Fix and Resolve Crashes（崩溃处理工具）"></a>Tools to Help You Fix and Resolve Crashes（崩溃处理工具）</h4><ul>
<li><p>Breakpoints </p>
</li>
<li><ul>
<li><p>直接打断点：（确定大概位置的情况下）</p>
</li>
<li><p>异常断点<code>(exception breakpoint)：Debug navigator</code>—- 左下角的+ —- 选择&#96;Exception Breakpoint</p>
<p>异常断点是由<code>Objective-C</code>运行时中发生的错误触发的，这在大多数情况下是<code>UIKit</code>内部的错误</p>
<p>异常断点会自动停止应用程序，并向您显示导致该行的行，有时崩溃可能是由于之前几行的错误所致，但是在该行终止</p>
</li>
<li></li>
</ul>
</li>
<li><p>Console Log：日志查看，结合LLDB 可以进行更多变量查看</p>
</li>
<li><p>Variables View：变量视图，与控制台日志类似，当应用程序未运行时，它将完全为空；但是，当应用程序执行时，它将保持当前终止时作用域中变量的值</p>
</li>
</ul>
<blockquote>
<p>Swift 常见崩溃问题</p>
<ul>
<li><strong>Force Unwrapping</strong>：强制解包可选型</li>
<li><strong>Weak References</strong>：弱引用链断裂</li>
<li><strong>Invalid Table Updates</strong>：无效界面更新</li>
<li>…….</li>
</ul>
</blockquote>
<h5 id="断言-在DEBUG模式下有效"><a href="#断言-在DEBUG模式下有效" class="headerlink" title="断言:在DEBUG模式下有效"></a>断言:在DEBUG模式下有效</h5><blockquote>
<p>assertionFailure(“Only Int or Strings are accepted in this function”)</p>
<p>断言仅在您的应用程序在调试<code>debug</code>配置下构建时起作用</p>
</blockquote>
<h5 id="Xcode-Simulator的高级功能"><a href="#Xcode-Simulator的高级功能" class="headerlink" title="Xcode Simulator的高级功能"></a>Xcode Simulator的高级功能</h5><p>思考：</p>
<blockquote>
<ul>
<li><p>什么是模拟器:</p>
<p>模拟器是运行在 macOS 内核上的独立用户空间</p>
<p><em><strong>用户空间</strong></em>是分配给运行应用程序的系统内存，</p>
<p><strong>内核空间</strong>是分配给运行操作系统内核和设备驱动程序的系统内存</p>
<p><em><strong>内核</strong></em>是操作系统的核心组成部分。它促进了硬件和软件组件之间的交互。它负责管理硬件、分配内存和在进程之间进行调度</p>
</li>
</ul>
</blockquote>
<blockquote>
<ul>
<li><p>深入了解有用的模拟器选项</p>
<ul>
<li><p>慢动画：Debug— Slow Animation</p>
</li>
<li><p>暗黑模式：Features —– Toggle Appearance</p>
</li>
<li><p>推动测试：*.apns*文件 —— 应用打开推送通知 —— 将推送文件拖到模拟器即可</p>
</li>
<li><blockquote>
<p>&#96;&#96;&#96;json<br>{<br>  “Simulator Target Bundle” :  “com.raywenderlich.RayWonders” , &#x2F;&#x2F;BundleID<br>  “aps” :  {<br>“alert” :  {<br>  “title” :  “已添加印地语支持！” ,<br>  “body” :  “在印地语中查看 RayWonders！”<br>}<br>  }<br>}</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line">  - 模拟位置： *启动定位服务* Features ----- Location ----- custom Location</span><br><span class="line"></span><br><span class="line">  - 从地图应用程序共享位置:（更高效的模拟定位的方式）</span><br><span class="line"></span><br><span class="line">macOS 上的*地图*应用程序提供了一种与模拟器共享位置的简单方法</span><br><span class="line"></span><br><span class="line">打开应用定位授权----确定地点---右键分享到模拟器</span><br><span class="line"></span><br><span class="line">  - 晃动： Device --- shake </span><br><span class="line"></span><br><span class="line">  - 模拟内存警告 Debug--- Simulate Memory Warming</span><br><span class="line">  </span><br><span class="line">  - 离屏渲染调试：Debug ---- color off-screen rendered</span><br><span class="line">  </span><br><span class="line">  </span><br><span class="line"></span><br><span class="line">- 从命令行创建和配置模拟器</span><br><span class="line"></span><br><span class="line">  *Simctl*是一种帮助管理模拟器并以编程方式与模拟器交互的工具</span><br><span class="line"></span><br><span class="line">```shell</span><br><span class="line">xcrun simctl --help</span><br><span class="line"></span><br><span class="line">	create              Create a new device.</span><br><span class="line">	clone               Clone an existing device.</span><br><span class="line">	upgrade             Upgrade a device to a newer runtime.</span><br><span class="line">	delete              Delete specified devices, unavailable devices, or all devices.</span><br><span class="line">	pair                Create a new watch and phone pair.</span><br><span class="line">	unpair              Unpair a watch and phone pair.</span><br><span class="line">	pair_activate       Set a given pair as active.</span><br><span class="line">	erase               Erase a device&#x27;s contents and settings.</span><br><span class="line">	boot                Boot a device or device pair.</span><br><span class="line">	shutdown            Shutdown a device.</span><br><span class="line">	rename              Rename a device.</span><br><span class="line">	getenv              Print an environment variable from a running device.</span><br><span class="line">	openurl             Open a URL in a device.</span><br><span class="line">	addmedia            Add photos, live photos, videos, or contacts to the library of a device.</span><br><span class="line">	install             Install an app on a device.</span><br><span class="line">	uninstall           Uninstall an app from a device.</span><br><span class="line">	get_app_container   Print the path of the installed app&#x27;s container</span><br><span class="line">	install_app_data    Install an xcappdata package to a device, replacing the current contents of the container.</span><br><span class="line">	launch              Launch an application by identifier on a device.</span><br><span class="line">	terminate           Terminate an application by identifier on a device.</span><br><span class="line">	spawn               Spawn a process by executing a given executable on a device.</span><br><span class="line">	list                List available devices, device types, runtimes, or device pairs.</span><br><span class="line">	icloud_sync         Trigger iCloud sync on a device.</span><br><span class="line">	pbsync              Sync the pasteboard content from one pasteboard to another.</span><br><span class="line">	pbcopy              Copy standard input onto the device pasteboard.</span><br><span class="line">	pbpaste             Print the contents of the device&#x27;s pasteboard to standard output.</span><br><span class="line">	help                Prints the usage for a given subcommand.</span><br><span class="line">	io                  Set up a device IO operation.</span><br><span class="line">	diagnose            Collect diagnostic information and logs.</span><br><span class="line">	logverbose          enable or disable verbose logging for a device</span><br><span class="line">	status_bar          Set or clear status bar overrides</span><br><span class="line">	ui                  Get or Set UI options</span><br><span class="line">	push                Send a simulated push notification</span><br><span class="line">	privacy             Grant, revoke, or reset privacy and permissions</span><br><span class="line">	keychain            Manipulate a device&#x27;s keychain</span><br><span class="line">	</span><br><span class="line">//查看列表</span><br><span class="line">xcrun simctl list</span><br><span class="line">启动模拟器</span><br><span class="line">xcrun simctl boot 5BADD878-1089-4A4C-811A-9698D85B425E</span><br><span class="line">安装APP</span><br><span class="line">xcrun simctl install 5BADD878-1089-4A4C-811A-9698D85B425E DemoSwift.app</span><br><span class="line">启动APP</span><br><span class="line">xcrun simctl launch 5BADD878-1089-4A4C-811A-9698D85B425E com.mdd.DemoSwift</span><br><span class="line">截图</span><br><span class="line">xcrun simctl io 5BADD878-1089-4A4C-811A-9698D85B425E screenshot screenshot.png --type=&quot;png&quot;</span><br><span class="line">get_app_container 打印应用程序包的路径</span><br><span class="line">xcrun simctl get_app_container 5BADD878-1089-4A4C-811A-9698D85B425E com.mdd.DemoSwift</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure></blockquote>
</li>
</ul>
</li>
</ul>
</blockquote>
<blockquote>
<ul>
<li>使用命令行流式传输和捕获日志<br>xcrun simctl spawn 5BADD878-1089-4A4C-811A-9698D85B425E log stream<br>xcrun simctl spawn 5BADD878-1089-4A4C-811A-9698D85B425E log stream | grep com.mdd.DemoSwift</li>
</ul>
</blockquote>
<blockquote>
<ul>
<li><p>创建 Bash 脚本以在不同语言环境的模拟器上自动启动应用程序</p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">touch sim_utility.sh    创建一个shell脚本文件</span><br><span class="line">    </span><br><span class="line">chmod +x sim_utility.sh  执行权限,使得sim_utility.sh可执行</span><br></pre></td></tr></table></figure>

<p>   #!&#x2F;bin&#x2F;bash</p>
<pre><code>#1
COMMAND=&quot;$1&quot;
SIMULATOR_NAME=&quot;$2&quot;
          
#2
get_id_of_simulator() &#123;
    #TODO
    xcrun simctl list | grep &quot;$SIMULATOR_NAME&quot; | \
    awk &#39;match($0, /\(([-0-9A-F]+)\)/) &#123;print substr( $0, RSTART + 1, RLENGTH-2 )&#125;&#39;
&#125;
          
get_status_of_simulator() &#123;
    #TODO
    xcrun simctl list | grep &quot;$SIMULATOR_NAME&quot; | \
    awk &#39;match($0, /\(([a-zA-Z]+)\)/) &#123;print substr( $0, RSTART + 1, RLENGTH - 2 )&#125;&#39;
&#125;
          
launch() &#123;
    #TODO
    #1
    BUNDLE_ID=&quot;$1&quot;
    LOCALE=&quot;$2&quot;
    LANGUAGE=&quot;$3&quot;
    CLONE_NAME=&quot;$LOCALE&quot;
    
</code></pre>
<p>  #2通过调用获取模拟器的 ID<br>SIMULATOR_ID&#x3D;$(get_id_of_simulator)<br>if [ -z “$SIMULATOR_ID” ]; then<br>echo “No device matching the name: $SIMULATOR_NAME”<br>return<br>fi<br><br>echo “Simulator id: $SIMULATOR_ID”<br>echo “Bundle id: $BUNDLE_ID”<br>echo “Locale: $LOCALE”<br><br>#3通过调用获取模拟器的状态<br>SIMULATOR_STATUS&#x3D;$(get_status_of_simulator)<br>echo “Simulator Status: $SIMULATOR_STATUS”<br>if [ “$SIMULATOR_STATUS” &#x3D; “Booted” ]; then<br>echo “Making sure the device is shutdown first…”<br>xcrun simctl shutdown “$SIMULATOR_NAME”<br>fi<br><br>#4使用clone命令克隆模拟器<br>echo “Cloning the device with name $LOCALE…”<br>xcrun simctl clone “$SIMULATOR_NAME” “$CLONE_NAME”<br><br>#5使用boot命令启动原始模拟器和克隆模拟器<br>echo “Booting device…”<br>xcrun simctl boot “$SIMULATOR_NAME”<br>xcrun simctl boot “$CLONE_NAME”<br><br>#6使用launch命令在原始模拟器上启动应用程序；<br>echo “Launching app…”<br>xcrun simctl launch “$SIMULATOR_NAME” “$BUNDLE_ID”<br><br>#7使用launch克隆模拟器上的命令启动应用程序<br>xcrun simctl launch “$CLONE_NAME” “$BUNDLE_ID” -AppleLocale “$LOCALE” <br>-AppleLanguages “($LANGUAGE)”<br>  }<br><br>#3<br>case $COMMAND in<br>“launch”) launch “$3” “$4” “$5” ;;<br>*)<br>launch_help<br>exit 1<br>;;<br>esac</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><span class="line">  #./sim_utility.sh launch 5BADD878-1089-4A4C-811A-9698D85B425E com.mdd.DemoSwift 5BADD878-1089-4A4C-811A-9698D85B425E</span><br><span class="line"></span><br><span class="line"></span><br><span class="line">##### xcode内存空间管理</span><br><span class="line"></span><br><span class="line">1. 清除派生数据 Derived data</span><br><span class="line"></span><br><span class="line">当您构建项目时，Xcode 会在您的*派生数据中*存储该项目的构建文件</span><br><span class="line"></span><br><span class="line">在 macOS 用户库中找到派生数据文件夹</span><br><span class="line"></span><br><span class="line">command+shift+G</span><br><span class="line"></span><br><span class="line">```bash</span><br><span class="line">~/Library/Developer/Xcode/DerivedData   </span><br></pre></td></tr></table></figure></li>
</ul>
<p><em>DerivedData 中的</em>所有内容都可以安全删除。实际上，清除派生数据是 iOS 开发人员解决烦人的编译问题的常用技巧</p>
<p>尽管删除派生数据是安全的，但是当 Xcode 从头开始构建您的项目时，您的构建将花费更长的时间</p>
</blockquote>
<ol start="2">
<li>清除归档数据 Clearing Archives</li>
</ol>
<blockquote>
<p> 每当您归档要在 TestFlight 或 App Store 上分发的应用程序时，该归档文件都会本地存储在您的 Mac 上。您可能有多年历史的档案等待清理。</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">实际的.xcarchive文件夹位于 Mac 上的~/Library/Developer/Xcode/Archives </span><br></pre></td></tr></table></figure>

<p>与派生数据不同，您的档案对您未来的构建没有影响；；它们是构建应用程序的成品，不会以任何方式加速编译。但这并不意味着您可以在空间不足时清除存档文件夹;</p>
<p>有时，保存旧档案可能是个好主意。如果您需要重新发布旧存档，则需要存储在存档文件夹中的*.xcarchive<em>。此外，调试应用程序的实时版本需要一个名为</em>dSYM*的特定文件，该文件打包在您的存档中(可以适当保留)</p>
</blockquote>
<ol start="3">
<li><p>清除模拟器 Clearing Simulators</p>
<blockquote>
<p>恢复出场设置：Device —-  <em>Erase All Content and Settings</em></p>
<p>擦除模拟器内容有助于清理您有权访问的模拟器。但是您可能会因为您甚至看不到的模拟器而丢失大量存储空间。</p>
</blockquote>
<blockquote>
<h3 id="删除不可用的模拟器"><a href="#删除不可用的模拟器" class="headerlink" title="删除不可用的模拟器:"></a>删除不可用的模拟器:</h3><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">xcrun simctl delete unavailable</span><br></pre></td></tr></table></figure>
</blockquote>
</li>
<li><p>设备支持文件清理 Device Support</p>
</li>
</ol>
<blockquote>
<p>当您将物理设备连接到 Mac 以安装或调试您的应用程序之一时，Xcode 会创建<em>设备支持</em>文件</p>
<p>Xcode 永远不会为您删除这些文件，因此它们往往会随着时间的推移而积累。幸运的是，自己删除它们没有坏处。每当您使用物理设备时，Xcode 都会自动安装设备支持文件</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">~/Library/Developer/Xcode/iOS DeviceSupport</span><br></pre></td></tr></table></figure>

<p>一个很好的建议是删除<em>iOS DeviceSupport</em>文件夹中除最新的两个 iOS 版本之外的所有版本，因为您可能仍会支持这些版本</p>
</blockquote>
<ol start="5">
<li><p>缓存 </p>
<blockquote>
<p><em>Xcode    ~&#x2F;Library&#x2F;Caches&#x2F;com.apple.dt.Xcode</em></p>
</blockquote>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pod cache clean --all   <span class="comment">#pod缓存</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>xcode清理脚本</p>
</li>
</ol>
 <figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="built_in">cd</span> ~/Desktop &amp;&amp; <span class="built_in">touch</span> clean-xcode.sh</span><br><span class="line"></span><br><span class="line"><span class="built_in">chmod</span> +x clean-xcode.sh</span><br><span class="line"></span><br><span class="line">./clean-xcode.sh  <span class="comment">#脚本运行</span></span><br></pre></td></tr></table></figure>



<hr>
<h5 id="崩溃日志的解析"><a href="#崩溃日志的解析" class="headerlink" title="崩溃日志的解析"></a>崩溃日志的解析</h5><p><strong>symbolication是解决回溯地址的源代码的方法或函数名的过程，称为符号化</strong></p>
<ol>
<li><p>涉及的角色：</p>
<blockquote>
<p>unsymbolicated崩溃日志（二进制文件上报的错误信息）、dSYM文件（调试符号文件）、可以定位到符号表的日志（symbolicated）</p>
<ul>
<li>调试符号文件和应用程序二进制文件与每一个build生成的UUID捆绑在一起</li>
</ul>
</blockquote>
</li>
<li><p>分析流程</p>
<blockquote>
<ul>
<li><p>崩溃日志的获取</p>
<blockquote>
<p>汇总部分包含崩溃发生环境的基本信息：</p>
<ul>
<li><p>Incident Identifier：日志ID。</p>
</li>
<li><p>CrashReport Key：设备匿名ID，同一设备的崩溃日志该值相同。</p>
</li>
<li><p>Beta Identifier：设备和崩溃应用组合ID。</p>
</li>
<li><p>Process：执行程序名，等同CFBundleExecutable。</p>
</li>
<li><p>Version：程序版本号，等同CFBundleVersion&#x2F;CFBundleVersionString。</p>
</li>
<li><p>Code type：程序构造：ARM-64、ARM、x86</p>
</li>
<li><p>Exception Codes：使用十六进制表示的程序特定信息，一般不展示。</p>
<p>Exception Subtype：易读（相比十六进制地址）的异常信息。</p>
<p>Exception Message：异常的额外信息。</p>
<p>Exception Note：不特指某种异常类型的额外信息。</p>
<p>Termination Reason：程序终止的异常信息。</p>
<p>Triggered Thread：异常发生时的线程</p>
</li>
<li><p>二进制镜像在程序内的地址空间</p>
<p>二进制的名称或者bundleID</p>
<p>二进制镜像的架构信息 arm64等</p>
<p>二进制镜像的UUID，每次构建都会改变，该值用于在符号化日志时定位对应的dSYM文件。</p>
<p>磁盘上的二进制路径</p>
</li>
</ul>
</blockquote>
</li>
<li><p>崩溃日志的<code>dSYM</code>反解析</p>
</li>
</ul>
</blockquote>
</li>
</ol>
<p>3.具体操作</p>
<ul>
<li><p>崩溃日志的获取：</p>
<ul>
<li>通过xcode的方式</li>
</ul>
<blockquote>
<p>如果你有Xcode可以使用它来获取崩溃日志，将崩溃的手机连接到Xcode上。从菜单栏上选择 <code>Window</code> 菜单，然后选择<code>Devices and Simulators</code>然后选择<code>View Device Logs</code>:可通过条件来筛选目标日志，右击你想看的日志，然后就可以选择<code>Export Log</code>进行导出</p>
</blockquote>
<ul>
<li>iTunes Connect 通过ITunes后台获取线上用户的崩溃日志（16年之后过期）</li>
<li><strong>通过xcode获取线上用户的崩溃日志（最新的最高效的方式）</strong></li>
</ul>
<blockquote>
<p>xcode上登录开发者账号—–点击上面的window 选择organizer—–左侧的crash</p>
<p>这种方式可以直接看到符号化过后的崩溃日志</p>
</blockquote>
<p><img src= "" data-lazy-src="/blog/2021/12/01/%E6%B5%8B%E8%AF%95%E4%B8%8E%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/1.png" alt="&quot;日志查询条件筛选&quot;"></p>
</li>
<li><p><strong>已经上传到Apple Store的包</strong>获取dSYM文件</p>
<blockquote>
<p>在<code>Archives organizer</code>，选择你之前提交到<code>App Store</code>的<code>Archive</code>文件选择<code>Download dSYM</code></p>
</blockquote>
</li>
</ul>
<ol start="4">
<li><strong>打出来的包没有.app.dSYM文件的原因</strong></li>
</ol>
<p>1）在<code>Build Settings</code>中，搜索<code>Debug Information Format</code>，查看值是否为<code>DWARF with dSYM File</code>。如果选为<code>DWARF</code>则不会产生<code>dSYM</code>文件，必须选择<code>DWARF with dSYM File</code>才会生成符号表文件</p>
<p>2） 在<code>Build Settings</code>中，搜索<code>Generate Debug Symbols</code>，看一下下面的值是否都为<code>Yes</code>，如果为<code>No</code>，则不会生成符号表文件，打出来的包也就找不到<code>.app.dSYM</code>文件</p>
<blockquote>
<p>总之，只有<code>Debug Information Format</code>为<code>DWARF with dSYM File</code> 且 <code>Generate Debug Symbols</code>为<code>YES</code>，这两个条件同时满足时，才能生成<code>.app.dYSM</code>文件</p>
</blockquote>
<p>5.原始崩溃日志解析</p>
<blockquote>
<ul>
<li><p><code>symbolicatecrash</code> 是Xcode自带的一个分析工具，可以通过机器上的崩溃日志和应用的<code>.dSYM</code>文件定位发生崩溃的位置，把crash日志中的地址替换成代码相应位置</p>
</li>
<li><p>命令行查找symbolicatecrash路劲：find &#x2F;Applications&#x2F;Xcode.app -name symbolicatecrash -type f</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/iOSSupport/Library/PrivateFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash</span><br><span class="line">/Applications/Xcode.app/Contents/Developer/Platforms/WatchSimulator.platform/Developer/Library/PrivateFrameworks/DVTFoundation.framework/symbolicatecrash</span><br><span class="line">/Applications/Xcode.app/Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/Library/PrivateFrameworks/DVTFoundation.framework/symbolicatecrash</span><br><span class="line">/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/PrivateFrameworks/DVTFoundation.framework/symbolicatecrash</span><br><span class="line"></span><br><span class="line"><span class="comment">#这个是需要的</span></span><br><span class="line">/Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/symbolicatecrash</span><br><span class="line"></span><br></pre></td></tr></table></figure>
</li>
<li><p>崩溃日志与<code>.dSYM</code>文件<strong>校验匹配</strong>：确保分析环境一致：关键步骤</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"></span><br><span class="line"><span class="comment">#首先获取dSYM的UUID： UUID: 47D636B5-FFA9-3384-A1ED-EDF5853A195E (arm64) MysteryBox.dSYM/Contents/Resources/DWARF/MysteryBox</span></span><br><span class="line">dwarfdump —uuid 文件路径/xxx.app.dSYM </span><br><span class="line"></span><br><span class="line"><span class="comment">#获取crash的 uuid</span></span><br><span class="line"><span class="comment">#0x102d9c000 -        0x102e17fff MysteryBox arm64  &lt;933c27ee1dc038b59761c2d54213c6a6&gt; /private/var/containers/Bundle/Application/F2C43F61-51B9-4971-B715-1220C281530B/MysteryBox.app/MysteryBox</span></span><br><span class="line">grep <span class="string">&quot;MysteryBox（这个是文件名称） arm&quot;</span> *.crash</span><br><span class="line"></span><br><span class="line"><span class="comment">#获取对应APP的 UUID: 47D636B5-FFA9-3384-A1ED-EDF5853A195E (arm64) MysteryBox.app/MysteryBox</span></span><br><span class="line">dwarfdump --uuid ~/MysteryBox.app/MysteryBox</span><br><span class="line"></span><br><span class="line"><span class="comment">#比对各个结果生成的ID信息</span></span><br></pre></td></tr></table></figure>
</li>
<li><p>将<code>symbolicatecrash</code>、解析前的崩溃日志、dSYM文件放在一个文件夹里，<code>cd</code>到目标文件夹,执行<code>symbolicatecrash</code></p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">./symbolicatecrash /Users/xxx/Desktop/Crash崩溃解析/11.crash /Users/xxx/Desktop/Crash崩溃解析/OneTravel.app.dSYM &gt; new_symbol.crash</span><br></pre></td></tr></table></figure>
</li>
<li><p>意外情况处理：</p>
<blockquote>
<ul>
<li><p>处理可能的报错:Error: “DEVELOPER_DIR” is not defined at .&#x2F;symbolicatecrash line 69.</p>
</li>
<li><pre><code class="bash">输入下面命令后重试解析操作 export DEVELOPER_DIR=&quot;/Applications/XCode.app/Contents/Developer&quot;
</code></pre>
</li>
</ul>
</blockquote>
<p>至此，解析完成。</p>
</li>
</ul>
</blockquote>
<p><strong>注意事项：</strong></p>
<p><strong>崩溃日志有三个阶段：</strong></p>
<blockquote>
<p><strong>无符号化原始日志—–&gt;半符号化日志（自定义调用无法显示符号化信息） ——&gt; 完全符号化日志</strong></p>
</blockquote>
<p><strong>如果使用Debug包上报的错误日志只能出现半符号化现象，那是因为在Build Setting构建设置下的Debug Infomation Format 的debug中设置为了DWARF,而非DWARF with dsYM file ，导致Debug下的二进制包的错误日志自定义方法无法关联到对应的调试符号文件dsYM file.</strong></p>
<ul>
<li><strong>解决方法：</strong><ul>
<li><strong>方案一：如果想要在Debug模式下查看，将Debug Infomation Format 的Debug 环境配置修改为DWARF with dsYM file</strong></li>
<li><strong>方案二：运行release包以实现错误日志收集</strong></li>
</ul>
</li>
</ul>
<p><img src= "" data-lazy-src="/blog/2021/12/01/%E6%B5%8B%E8%AF%95%E4%B8%8E%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/.2.png"></p>
<hr>
<h5 id="使用atos进行分析"><a href="#使用atos进行分析" class="headerlink" title="使用atos进行分析"></a>使用atos进行分析</h5><p><img src= "" data-lazy-src="/blog/2021/12/01/%E6%B5%8B%E8%AF%95%E4%B8%8E%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/2222.png" alt="&quot;日志查询条件筛选&quot;"></p>
<figure class="highlight shell"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">atos -arch arm64 -o /Users/albertyuan/Desktop/crashAnalyze/JuMingNet.app.dSYM/Contents/Resources/DWARF/JuMingNet  -l 0x100b2c000 0x0000000100fc3d24</span><br><span class="line"></span><br><span class="line">atos -arch 架构 -o dSYM信息（Binary Image Name） -l 加载地址(loadAddress) 错误地址(symbolicate address)</span><br></pre></td></tr></table></figure>



</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">Albert Yuan</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://yllove.gitee.io/2021/12/01/%E6%B5%8B%E8%AF%95%E4%B8%8E%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/">https://yllove.gitee.io/2021/12/01/%E6%B5%8B%E8%AF%95%E4%B8%8E%E7%AE%A1%E7%90%86/ios%E5%B4%A9%E6%BA%83%E8%B0%83%E8%AF%95%E4%B8%8Excode%E9%AB%98%E7%BA%A7%E7%AE%A1%E7%90%86/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://yllove.gitee.io" target="_blank">Albert Yuan's Blog</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/blog/tags/iOS%E6%B5%8B%E8%AF%95/">iOS测试</a></div><div class="post_share"><div class="social-share" data-image="/blog/img/defaultCover.png" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://fastly.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://fastly.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/blog/2021/11/24/iOS/ios%E8%87%AA%E5%AE%9A%E4%B9%89%E6%B8%90%E8%BF%9B%E6%BB%9A%E5%8A%A8%E8%A7%86%E5%9B%BE/"><img class="prev-cover" src= "" data-lazy-src="/blog/img/defaultCover.png" onerror="onerror=null;src='/blog/img/defaultCover.gif'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">ios自定义渐进滚动视图</div></div></a></div><div class="next-post pull-right"><a href="/blog/2021/12/01/OpenGL%E5%BC%80%E5%8F%91/OpenGL%E5%9F%BA%E7%A1%80%E6%A6%82%E5%BF%B5%E5%88%9D%E8%AF%86/"><img class="next-cover" src= "" data-lazy-src="/blog/img/defaultCover.png" onerror="onerror=null;src='/blog/img/defaultCover.gif'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">OpenGL基础概念初识</div></div></a></div></nav><hr/><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i><span> 评论</span></div></div><div class="comment-wrap"><div><div class="vcomment" id="vcomment"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="is-center"><div class="avatar-img"><img src= "" data-lazy-src="/blog/img/favicon.png" onerror="this.onerror=null;this.src='/blog/img/friend_404.gif'" alt="avatar"/></div><div class="author-info__name">Albert Yuan</div><div class="author-info__description">博学之,审问之,慎思之,明辨之,笃行之</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/blog/archives/"><div class="headline">文章</div><div class="length-num">155</div></a></div><div class="card-info-data-item is-center"><a href="/blog/tags/"><div class="headline">标签</div><div class="length-num">56</div></a></div><div class="card-info-data-item is-center"><a href="/blog/categories/"><div class="headline">分类</div><div class="length-num">32</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/yuanliangYL"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://github.com/yuanliangYL" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:yuanliangios@163.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a><a class="social-icon" href="qq:1023817403" target="_blank" title="QQ"><i class="fab fa-qq"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">love cat , love life</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-4"><a class="toc-link" href="#Tools-to-Help-You-Fix-and-Resolve-Crashes%EF%BC%88%E5%B4%A9%E6%BA%83%E5%A4%84%E7%90%86%E5%B7%A5%E5%85%B7%EF%BC%89"><span class="toc-text">Tools to Help You Fix and Resolve Crashes（崩溃处理工具）</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E6%96%AD%E8%A8%80-%E5%9C%A8DEBUG%E6%A8%A1%E5%BC%8F%E4%B8%8B%E6%9C%89%E6%95%88"><span class="toc-text">断言:在DEBUG模式下有效</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#Xcode-Simulator%E7%9A%84%E9%AB%98%E7%BA%A7%E5%8A%9F%E8%83%BD"><span class="toc-text">Xcode Simulator的高级功能</span></a></li></ol></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%88%A0%E9%99%A4%E4%B8%8D%E5%8F%AF%E7%94%A8%E7%9A%84%E6%A8%A1%E6%8B%9F%E5%99%A8"><span class="toc-text">删除不可用的模拟器:</span></a><ol class="toc-child"><li class="toc-item toc-level-5"><a class="toc-link" href="#%E5%B4%A9%E6%BA%83%E6%97%A5%E5%BF%97%E7%9A%84%E8%A7%A3%E6%9E%90"><span class="toc-text">崩溃日志的解析</span></a></li><li class="toc-item toc-level-5"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8atos%E8%BF%9B%E8%A1%8C%E5%88%86%E6%9E%90"><span class="toc-text">使用atos进行分析</span></a></li></ol></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/blog/2023/02/07/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BD%91%E9%A1%B5%E4%B8%8B%E8%BD%BDIPA%E5%8C%85/" title="iOS 自定义网页下载IPA包"><img src= "" data-lazy-src="https://img.mp.itc.cn/upload/20170409/1a8f793d7282451cbd1beb6841608c90_th.jpeg" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="iOS 自定义网页下载IPA包"/></a><div class="content"><a class="title" href="/blog/2023/02/07/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS-%E8%87%AA%E5%AE%9A%E4%B9%89%E7%BD%91%E9%A1%B5%E4%B8%8B%E8%BD%BDIPA%E5%8C%85/" title="iOS 自定义网页下载IPA包">iOS 自定义网页下载IPA包</a><time datetime="2023-02-07T02:46:29.851Z" title="更新于 2023-02-07 10:46:29">2023-02-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2023/02/06/Flutter/Flutter%E6%8E%A5%E5%85%A5%E5%8E%9F%E7%94%9F-iOS/" title="flutter接入原生-iOS"><img src= "" data-lazy-src="https://pic4.zhimg.com/v2-6a115fea4db1ad770dccf4119bfab36f_1440w.jpg?source=172ae18b" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="flutter接入原生-iOS"/></a><div class="content"><a class="title" href="/blog/2023/02/06/Flutter/Flutter%E6%8E%A5%E5%85%A5%E5%8E%9F%E7%94%9F-iOS/" title="flutter接入原生-iOS">flutter接入原生-iOS</a><time datetime="2023-02-07T01:18:53.661Z" title="更新于 2023-02-07 09:18:53">2023-02-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2022/12/17/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS%20%E5%A6%82%E4%BD%95%E5%9C%A8%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%B8%AD%E5%AE%89%E8%A3%85APP/" title="iOS 如何在模拟器中安装APP"><img src= "" data-lazy-src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fwww.winwin7.com%2Fuploadfile%2F2021%2F0114%2F20210114141748239.jpg&amp;refer=http%3A%2F%2Fwww.winwin7.com&amp;app=2002&amp;size=f9999,10000&amp;q=a80&amp;n=0&amp;g=0n&amp;fmt=auto?sec=1673854539&amp;t=aad2108ffb799b04e94a28cc58f038f1" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="iOS 如何在模拟器中安装APP"/></a><div class="content"><a class="title" href="/blog/2022/12/17/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/iOS%20%E5%A6%82%E4%BD%95%E5%9C%A8%E6%A8%A1%E6%8B%9F%E5%99%A8%E4%B8%AD%E5%AE%89%E8%A3%85APP/" title="iOS 如何在模拟器中安装APP">iOS 如何在模拟器中安装APP</a><time datetime="2022-12-17T07:48:56.594Z" title="更新于 2022-12-17 15:48:56">2022-12-17</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2021/08/05/Swift/swift%E5%B8%B8%E7%94%A8%E4%B8%89%E6%96%B9%E5%BA%93/" title="swift常用三方库"><img src= "" data-lazy-src="https://photos.infinum.com/store/b558bd40787ecad225d9c66322f14522" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="swift常用三方库"/></a><div class="content"><a class="title" href="/blog/2021/08/05/Swift/swift%E5%B8%B8%E7%94%A8%E4%B8%89%E6%96%B9%E5%BA%93/" title="swift常用三方库">swift常用三方库</a><time datetime="2022-12-16T06:37:20.115Z" title="更新于 2022-12-16 14:37:20">2022-12-16</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/blog/2022/12/12/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/GCD%E8%BF%9B%E9%98%B6%E4%B9%8BDispatchWorkItem%E5%92%8CDispatchGroup/" title="GCD进阶之DispatchWorkItem和DispatchGroup"><img src= "" data-lazy-src="/blog/img/defaultCover.png" onerror="this.onerror=null;this.src='/blog/img/defaultCover.gif'" alt="GCD进阶之DispatchWorkItem和DispatchGroup"/></a><div class="content"><a class="title" href="/blog/2022/12/12/iOS%E5%BC%80%E5%8F%91%E8%BF%9B%E9%98%B6/GCD%E8%BF%9B%E9%98%B6%E4%B9%8BDispatchWorkItem%E5%92%8CDispatchGroup/" title="GCD进阶之DispatchWorkItem和DispatchGroup">GCD进阶之DispatchWorkItem和DispatchGroup</a><time datetime="2022-12-12T07:19:37.277Z" title="更新于 2022-12-12 15:19:37">2022-12-12</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('/blog/img/defaultCover.png')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2023 By Albert Yuan</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div><div class="footer_custom_text">Hi, welcom to my  blog</div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><a id="to_comment" href="#post-comment" title="直达评论"><i class="fas fa-comments"></i></a><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="algolia-search"><div class="search-dialog"><div class="search-dialog__title" id="algolia-search-title">Algolia</div><div id="algolia-input-panel"><div id="algolia-search-input"></div></div><hr/><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-stats"></div></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/blog/js/utils.js"></script><script src="/blog/js/main.js"></script><script src="https://fastly.jsdelivr.net/npm/vanilla-lazyload/dist/lazyload.iife.min.js"></script><script src="/blog/js/search/algolia.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"><script>if (!window.MathJax) {
  window.MathJax = {
    tex: {
      inlineMath: [ ['$','$'], ["\\(","\\)"]],
      tags: 'ams'
    },
    chtml: {
      scale: 1.2
    },
    options: {
      renderActions: {
        findScript: [10, doc => {
          for (const node of document.querySelectorAll('script[type^="math/tex"]')) {
            const display = !!node.type.match(/; *mode=display/)
            const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display)
            const text = document.createTextNode('')
            node.parentNode.replaceChild(text, node)
            math.start = {node: text, delim: '', n: 0}
            math.end = {node: text, delim: '', n: 0}
            doc.math.push(math)
          }
        }, ''],
        insertScript: [200, () => {
          document.querySelectorAll('mjx-container:not\([display]\)').forEach(node => {
            const target = node.parentNode
            if (target.nodeName.toLowerCase() === 'li') {
              target.parentNode.classList.add('has-jax')
            } else {
              target.classList.add('has-jax')
            }
          });
        }, '', false]
      }
    }
  }
  
  const script = document.createElement('script')
  script.src = 'https://fastly.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js'
  script.id = 'MathJax-script'
  script.async = true
  document.head.appendChild(script)
} else {
  MathJax.startup.document.state(0)
  MathJax.texReset()
  MathJax.typeset()
}</script><script>function loadValine () {
  function initValine () {
    const valine = new Valine(Object.assign({
      el: '#vcomment',
      appId: 'REc8eytE1gJDl3d8FkudLNlL-gzGzoHsz',
      appKey: 'gGO3y8I9oVlc4Cd5N1fizNPW',
      avatar: 'monsterid',
      serverURLs: '',
      emojiMaps: "",
      path: window.location.pathname,
      visitor: false
    }, null))
  }

  if (typeof Valine === 'function') initValine() 
  else getScript('https://fastly.jsdelivr.net/npm/valine/dist/Valine.min.js').then(initValine)
}

if ('Valine' === 'Valine' || !true) {
  if (true) btf.loadComment(document.getElementById('vcomment'),loadValine)
  else setTimeout(loadValine, 0)
} else {
  function loadOtherComment () {
    loadValine()
  }
}</script></div><script defer="defer" id="fluttering_ribbon" mobile="true" src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-fluttering-ribbon.min.js"></script><script id="canvas_nest" defer="defer" color="255,0,0" opacity="0.7" zIndex="-1" count="99" mobile="false" src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-nest.min.js"></script><script src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = true;
document.body.addEventListener('input', POWERMODE);
</script><script id="click-heart" src="https://fastly.jsdelivr.net/npm/butterfly-extsrc@1/dist/click-heart.min.js" async="async" mobile="false"></script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>